package com.bhs.sansonglogistics.utils;

import android.graphics.Color;
import android.os.CountDownTimer;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.style.ForegroundColorSpan;
import android.widget.TextView;

/**
 * @data on 2020/10/16 6:26 PM
 * @auther armstrong
 * @describe 倒计时工具类
 */
public class CountDownTimerUtils extends CountDownTimer {
    private TextView mTextView;
    private String title;
    public CountDownTimerUtils(TextView textView, long millisInFuture,String title) {
        super(millisInFuture, 1000);
        this.mTextView = textView;
        this.title=title;
    }

    @Override
    public void onTick(long millisUntilFinished) {
        mTextView.setText(String.format("%s (倒计时 %s)",title,DateUtils.timeParse(millisUntilFinished)));  //设置倒计时时间
    }

    @Override
    public void onFinish() {
        mTextView.setText(title);
    }
}